package com.sistemas.mse.servicio.holamunudo;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.sistemas.mse.model.Product;

@Service
public class SimpleProductManager implements ProductManager{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<Product> lstProducts;
	
	@Override
	public void increasePrice(int percentage) {
		 if (lstProducts != null) {
	            for (Product product : lstProducts) {
	                double newPrice = product.getPrice().doubleValue() * 
	                                    (100 + percentage)/100;
	                product.setPrice(newPrice);
	            }
	        }  	}

	@Override
	public List<Product> getProducts() {
		 return lstProducts;
	
	}

	
	 public void setProducts(List<Product> products) {
	       this.lstProducts = products;     
	    }

	@Override
	public List<Product> getProductsMock() {
	List<Product> lstProducts = new ArrayList<Product>();
		
		for (int i = 1; i<3;i++){
			Product p = new Product();
			p.setDescription("Product "+i);
			p.setPrice(new Double(i*10));
			lstProducts.add(p);
		}
		
		this.lstProducts = lstProducts;
		return lstProducts;
	}
}
